3.242 \(\int (a+b \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx\)

Optimal. Leaf size=87 \[ -\frac{\left (a^2 B+2 a A b-b^2 B\right ) \log (\cos (c+d x))}{d}+x \left (a^2 A-2 a b B-A b^2\right )+\frac{b (a B+A b) \tan (c+d x)}{d}+\frac{B (a+b \tan (c+d x))^2}{2 d} \]

[Out]

(a^2*A - A*b^2 - 2*a*b*B)*x - ((2*a*A*b + a^2*B - b^2*B)*Log[Cos[c + d*x]])/d + (b*(A*b + a*B)*Tan[c + d*x])/d
 + (B*(a + b*Tan[c + d*x])^2)/(2*d)

________________________________________________________________________________________

Rubi [A]  time = 0.0757501, antiderivative size = 87, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 3, integrand size = 23, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.13, Rules used = {3528, 3525, 3475} \[ -\frac{\left (a^2 B+2 a A b-b^2 B\right ) \log (\cos (c+d x))}{d}+x \left (a^2 A-2 a b B-A b^2\right )+\frac{b (a B+A b) \tan (c+d x)}{d}+\frac{B (a+b \tan (c+d x))^2}{2 d} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Tan[c + d*x])^2*(A + B*Tan[c + d*x]),x]

[Out]

(a^2*A - A*b^2 - 2*a*b*B)*x - ((2*a*A*b + a^2*B - b^2*B)*Log[Cos[c + d*x]])/d + (b*(A*b + a*B)*Tan[c + d*x])/d
 + (B*(a + b*Tan[c + d*x])^2)/(2*d)

Rule 3528

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(d
*(a + b*Tan[e + f*x])^m)/(f*m), x] + Int[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x
], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && GtQ[m, 0]

Rule 3525

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[(b*d*Tan[e + f*x])/f, x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int (a+b \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx &=\frac{B (a+b \tan (c+d x))^2}{2 d}+\int (a+b \tan (c+d x)) (a A-b B+(A b+a B) \tan (c+d x)) \, dx\\ &=\left (a^2 A-A b^2-2 a b B\right ) x+\frac{b (A b+a B) \tan (c+d x)}{d}+\frac{B (a+b \tan (c+d x))^2}{2 d}+\left (2 a A b+a^2 B-b^2 B\right ) \int \tan (c+d x) \, dx\\ &=\left (a^2 A-A b^2-2 a b B\right ) x-\frac{\left (2 a A b+a^2 B-b^2 B\right ) \log (\cos (c+d x))}{d}+\frac{b (A b+a B) \tan (c+d x)}{d}+\frac{B (a+b \tan (c+d x))^2}{2 d}\\ \end{align*}

Mathematica [C]  time = 0.441482, size = 96, normalized size = 1.1 \[ \frac{2 b (2 a B+A b) \tan (c+d x)+(a-i b)^2 (B+i A) \log (\tan (c+d x)+i)+(a+i b)^2 (B-i A) \log (-\tan (c+d x)+i)+b^2 B \tan ^2(c+d x)}{2 d} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Tan[c + d*x])^2*(A + B*Tan[c + d*x]),x]

[Out]

((a + I*b)^2*((-I)*A + B)*Log[I - Tan[c + d*x]] + (a - I*b)^2*(I*A + B)*Log[I + Tan[c + d*x]] + 2*b*(A*b + 2*a
*B)*Tan[c + d*x] + b^2*B*Tan[c + d*x]^2)/(2*d)

________________________________________________________________________________________

Maple [A]  time = 0.013, size = 151, normalized size = 1.7 \begin{align*}{\frac{{b}^{2}B \left ( \tan \left ( dx+c \right ) \right ) ^{2}}{2\,d}}+{\frac{A{b}^{2}\tan \left ( dx+c \right ) }{d}}+2\,{\frac{Bab\tan \left ( dx+c \right ) }{d}}+{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) Aab}{d}}+{\frac{{a}^{2}B\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) }{2\,d}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ){b}^{2}B}{2\,d}}+{\frac{{a}^{2}A\arctan \left ( \tan \left ( dx+c \right ) \right ) }{d}}-{\frac{A\arctan \left ( \tan \left ( dx+c \right ) \right ){b}^{2}}{d}}-2\,{\frac{B\arctan \left ( \tan \left ( dx+c \right ) \right ) ab}{d}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*tan(d*x+c))^2*(A+B*tan(d*x+c)),x)

[Out]

1/2/d*b^2*B*tan(d*x+c)^2+1/d*A*b^2*tan(d*x+c)+2/d*B*a*b*tan(d*x+c)+1/d*ln(1+tan(d*x+c)^2)*A*a*b+1/2/d*a^2*B*ln
(1+tan(d*x+c)^2)-1/2/d*ln(1+tan(d*x+c)^2)*b^2*B+1/d*a^2*A*arctan(tan(d*x+c))-1/d*A*arctan(tan(d*x+c))*b^2-2/d*
B*arctan(tan(d*x+c))*a*b

________________________________________________________________________________________

Maxima [A]  time = 1.47194, size = 123, normalized size = 1.41 \begin{align*} \frac{B b^{2} \tan \left (d x + c\right )^{2} + 2 \,{\left (A a^{2} - 2 \, B a b - A b^{2}\right )}{\left (d x + c\right )} +{\left (B a^{2} + 2 \, A a b - B b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 2 \,{\left (2 \, B a b + A b^{2}\right )} \tan \left (d x + c\right )}{2 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

1/2*(B*b^2*tan(d*x + c)^2 + 2*(A*a^2 - 2*B*a*b - A*b^2)*(d*x + c) + (B*a^2 + 2*A*a*b - B*b^2)*log(tan(d*x + c)
^2 + 1) + 2*(2*B*a*b + A*b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Fricas [A]  time = 2.03688, size = 209, normalized size = 2.4 \begin{align*} \frac{B b^{2} \tan \left (d x + c\right )^{2} + 2 \,{\left (A a^{2} - 2 \, B a b - A b^{2}\right )} d x -{\left (B a^{2} + 2 \, A a b - B b^{2}\right )} \log \left (\frac{1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 2 \,{\left (2 \, B a b + A b^{2}\right )} \tan \left (d x + c\right )}{2 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

1/2*(B*b^2*tan(d*x + c)^2 + 2*(A*a^2 - 2*B*a*b - A*b^2)*d*x - (B*a^2 + 2*A*a*b - B*b^2)*log(1/(tan(d*x + c)^2
+ 1)) + 2*(2*B*a*b + A*b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Sympy [A]  time = 0.371607, size = 143, normalized size = 1.64 \begin{align*} \begin{cases} A a^{2} x + \frac{A a b \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{d} - A b^{2} x + \frac{A b^{2} \tan{\left (c + d x \right )}}{d} + \frac{B a^{2} \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 2 B a b x + \frac{2 B a b \tan{\left (c + d x \right )}}{d} - \frac{B b^{2} \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac{B b^{2} \tan ^{2}{\left (c + d x \right )}}{2 d} & \text{for}\: d \neq 0 \\x \left (A + B \tan{\left (c \right )}\right ) \left (a + b \tan{\left (c \right )}\right )^{2} & \text{otherwise} \end{cases} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))**2*(A+B*tan(d*x+c)),x)

[Out]

Piecewise((A*a**2*x + A*a*b*log(tan(c + d*x)**2 + 1)/d - A*b**2*x + A*b**2*tan(c + d*x)/d + B*a**2*log(tan(c +
 d*x)**2 + 1)/(2*d) - 2*B*a*b*x + 2*B*a*b*tan(c + d*x)/d - B*b**2*log(tan(c + d*x)**2 + 1)/(2*d) + B*b**2*tan(
c + d*x)**2/(2*d), Ne(d, 0)), (x*(A + B*tan(c))*(a + b*tan(c))**2, True))

________________________________________________________________________________________

Giac [B]  time = 1.93693, size = 1216, normalized size = 13.98 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

1/2*(2*A*a^2*d*x*tan(d*x)^2*tan(c)^2 - 4*B*a*b*d*x*tan(d*x)^2*tan(c)^2 - 2*A*b^2*d*x*tan(d*x)^2*tan(c)^2 - B*a
^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(
d*x)*tan(c) + 1))*tan(d*x)^2*tan(c)^2 - 2*A*a*b*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c
) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)^2*tan(c)^2 + B*b^2*log(4*(tan(c)^2 + 1
)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(
d*x)^2*tan(c)^2 - 4*A*a^2*d*x*tan(d*x)*tan(c) + 8*B*a*b*d*x*tan(d*x)*tan(c) + 4*A*b^2*d*x*tan(d*x)*tan(c) + B*
b^2*tan(d*x)^2*tan(c)^2 + 2*B*a^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2
*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)*tan(c) + 4*A*a*b*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*ta
n(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)*tan(c) - 2*
B*b^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*t
an(d*x)*tan(c) + 1))*tan(d*x)*tan(c) - 4*B*a*b*tan(d*x)^2*tan(c) - 2*A*b^2*tan(d*x)^2*tan(c) - 4*B*a*b*tan(d*x
)*tan(c)^2 - 2*A*b^2*tan(d*x)*tan(c)^2 + 2*A*a^2*d*x - 4*B*a*b*d*x - 2*A*b^2*d*x + B*b^2*tan(d*x)^2 + B*b^2*ta
n(c)^2 - B*a^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x
)^2 - 2*tan(d*x)*tan(c) + 1)) - 2*A*a*b*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(
d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)) + B*b^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*t
an(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)) + 4*B*a*b*tan(d*x) + 2*A*b^2*tan
(d*x) + 4*B*a*b*tan(c) + 2*A*b^2*tan(c) + B*b^2)/(d*tan(d*x)^2*tan(c)^2 - 2*d*tan(d*x)*tan(c) + d)